//
//  DiscoverTableViewController.m
//  TeamProject_1.0
//
//  Created by lanou3g on 15/12/7.
//  Copyright © 2015年 wey. All rights reserved.
//

#import "DiscoverTableViewController.h"

@interface DiscoverTableViewController ()
@property (nonatomic, strong) NSArray *titles;
@property (nonatomic, strong) NSMutableArray *images;
@end

@implementation DiscoverTableViewController

- (NSMutableArray *)images {
    
    if (!_images) {
        _images = [NSMutableArray array];
    }
    return _images;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tableView.rowHeight = 45.0;
    [self setUpData];
    
}

- (void)setUpData {
    
    self.tableView.rowHeight = 60;
    self.titles = @[];
    NSArray *imgPath = @[];
    for (int i= 0; i<imgPath.count; i++) {
        [self.images addObject:[UIImage imageNamed:imgPath[i]]];
    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

#pragma mark - Table view data source // section cell 个数在SB中设置

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    //TODO :可能在这里添加地图
    NSInteger count = 0;
    if (section == 1) {
        count = 2;
    } else if (section == 2) {
        count =2;
    }
    return count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    ///  新建cell 不需要重用
    UITableViewCell *cell = [[UITableViewCell alloc]init];
    cell.selectionStyle = UITableViewCellSeparatorStyleNone;
    cell.separatorInset = UIEdgeInsetsMake(0, 15, 0, 0);
    
    ///  设置不同section的标题
    NSLog(@"%ld,%ld",indexPath.section,indexPath.row);
    switch (indexPath.section) {
        case 0:
            cell.textLabel.text = @"好友圈";
            cell.imageView.image = [UIImage imageNamed:@"discover-events"];
            break;
        case 1:
            cell.textLabel.text = @[@"找人", @"活动"][indexPath.row];
            cell.imageView.image = [UIImage imageNamed:@[@"discover-search", @"discover-activities"][indexPath.row]];
            break;
        case 2:
            cell.textLabel.text = @[@"扫一扫", @"摇一摇"][indexPath.row];
            cell.imageView.image = [UIImage imageNamed:@[@"discover-scan", @"discover-shake"][indexPath.row]];
            break;
    }
    
    return cell;
    
}

///  section 高度
- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 24.0;
}

///  点击时间

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    NSIndexPath *index = [NSIndexPath new]; //
    
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
    switch (indexPath.section) {
        case 0:
            if (indexPath.row ==0) {
                index = indexPath;
            }
            break;
            
        case 1:
            if (indexPath.row == 0) {
                index = indexPath;
            }else if (indexPath.row == 1) {
                index = indexPath;
            }
            break;
            
        case 2:
            if (indexPath.row == 0) {
                index = indexPath;
            }else if (indexPath.row == 1) {
                index = indexPath;
            }
    
        default:
            break;
    }
    NSLog(@"点击 %ld,%ld",index.section,index.row);
}


/** 左按钮点击 */
- (IBAction)leftBarButton:(id)sender {
    [self.sideMenuViewController presentLeftMenuViewController];
    
}
@end
